using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using PXP.Core;

namespace util
{
    //ths class was originaly made to ask the user of the password to a channel, but I remaded it as a genarick prompt for one line user input
    class getPassDia : PXPForm
    {
        public const int OK = 1;
        public const int CANCEL = 2;
        public int exit_opp = 2;//is OK or Cnacel depending on what the user clicked
        public String message="";//message prompt for user
        public String UserIN="";//is set one close with what the user inputed
        public bool isPass = true;//if true use password char
        private Button ok = new Button();
        private Button cancel = new Button();
        private Label label = new Label();
        private TextBox tb = new TextBox();

        public getPassDia(String message)
        {
            exit_opp = CANCEL;
            this.message = message;

            label.Text = message;
            label.Location = new System.Drawing.Point(10, 10);
            label.Size = new System.Drawing.Size(370, label.Size.Height);
            this.pnlMainContainer.Controls.Add(label);

            tb.Size = new System.Drawing.Size(370, tb.Size.Height);
            tb.Location = new System.Drawing.Point(10, 10 + label.Size.Height + 3);
            this.pnlMainContainer.Controls.Add(tb);

            ok.Click += new EventHandler(ok_Click);
            ok.Text = "Ok";
            ok.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            ok.Location = new System.Drawing.Point(10, tb.Location.Y + tb.Size.Height + 5);
            this.pnlMainContainer.Controls.Add(ok);

            cancel.Click += new EventHandler(cancel_Click);
            cancel.Text = "Cancel";
            cancel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            cancel.Location = new System.Drawing.Point(ok.Location.X + ok.Size.Width + 10, tb.Location.Y + tb.Size.Height + 5);
            this.pnlMainContainer.Controls.Add(cancel);

            this.ClientSize = new System.Drawing.Size(400, 210);
        }
        private void ok_Click(object o, EventArgs e)
        {
            exit_opp = OK;
            UserIN = tb.Text;
            this.Close();
        }
        private void cancel_Click(object o, EventArgs e)
        {
            exit_opp = CANCEL;
            this.Close();
        }
        public void setPassedChar(char c)
        {
            tb.PasswordChar = c;
        }
    }
    //used to prompt user for all infromation need to conect to a TS server
    class conectDia : PXPForm
    {
        public const int OK = 1;
        public const int CANCEL = 2;
        public int exit_opp = 2;
        public String ip = "";
        public String nick = "";
        public String logname = "";
        public String pass = "";

        private Button conect = new Button();
        private Button cancel = new Button();
        private Label ipL = new Label();
        private Label nickL = new Label();
        private Label lognameL = new Label();
        private Label passL = new Label();
        private TextBox ipB = new TextBox();
        private TextBox nickB = new TextBox();
        private TextBox lognameB = new TextBox();
        private TextBox passB = new TextBox();

        public conectDia()
        {
            this.ClientSize = new System.Drawing.Size(330, 370);
            this.Text = "Cnnection Dialog";

            ipL.Text = "Server Address:";
            ipL.Location = new System.Drawing.Point(10, 10);
            ipL.Size = new System.Drawing.Size(270, ipL.Size.Height);
            this.pnlMainContainer.Controls.Add(ipL);

            ipB.Location = new System.Drawing.Point(10, 10 + ipL.Size.Height);
            ipB.Size = new System.Drawing.Size(270, ipB.Size.Height);
            this.pnlMainContainer.Controls.Add(ipB);

            nickL.Text = "Nickname:";
            nickL.Location = new System.Drawing.Point(10, ipB.Location.Y + ipB.Size.Height+ 10);
            nickL.Size = new System.Drawing.Size(270, nickL.Size.Height);
            this.pnlMainContainer.Controls.Add(nickL);

            nickB.Location = new System.Drawing.Point(10, nickL.Location.Y + nickL.Size.Height);
            nickB.Size = new System.Drawing.Size(270, nickB.Size.Height);
            this.pnlMainContainer.Controls.Add(nickB);

            lognameL.Text = "Login Name(optional):";
            lognameL.Location = new System.Drawing.Point(10, nickB.Location.Y + nickB.Size.Height + 10);
            lognameL.Size = new System.Drawing.Size(270, lognameL.Size.Height);
            this.pnlMainContainer.Controls.Add(lognameL);

            lognameB.Location = new System.Drawing.Point(10, lognameL.Location.Y + lognameL.Size.Height);
            lognameB.Size = new System.Drawing.Size(270,lognameB.Size.Height);
            this.pnlMainContainer.Controls.Add(lognameB);

            passL.Text = "Password:";
            passL.Location = new System.Drawing.Point(10, lognameB.Location.Y + lognameB.Size.Height + 10);
            passL.Size = new System.Drawing.Size(270, passL.Size.Height);
            this.pnlMainContainer.Controls.Add(passL);

            passB.Location = new System.Drawing.Point(10, passL.Location.Y + passL.Size.Height);
            passB.Size = new System.Drawing.Size(270, passB.Size.Height);
            passB.PasswordChar = '*';
            this.pnlMainContainer.Controls.Add(passB);

            conect.Text = "Connect";
            conect.Click +=new EventHandler(conect_Click);
            conect.Location = new System.Drawing.Point(10, passB.Location.Y + passB.Size.Height + 10);
            this.pnlMainContainer.Controls.Add(conect);

            cancel.Text = "Cancel";
            cancel.Click += new EventHandler(cancel_Click);
            cancel.Location = new System.Drawing.Point(conect.Location.X + conect.Size.Width + 20, conect.Location.Y);
            this.pnlMainContainer.Controls.Add(cancel);

        }
        private void conect_Click(object o, EventArgs e)
        {
            exit_opp = OK;
            ip = ipB.Text;
            logname = lognameB.Text;
            nick = nickB.Text;
            pass = passB.Text;
            this.Close();
        }
        private void cancel_Click(object o, EventArgs e)
        {
            exit_opp = CANCEL;
            this.Close();
        }
    }
}
